

cflags =  -g  -Wall -Wstrict-prototypes \
	      -march=i386 -mregparm=3 \
              -include code16gcc.h \
              -fno-strict-aliasing -fomit-frame-pointer \
              -ffreestanding \
              -fno-toplevel-reorder\
              -fno-unit-at-a-time \
              -fno-stack-protector \
              -mpreferred-stack-boundary=2 \
	      -mno-sse -mno-mmx -mno-sse2 -mno-3dnow \
	      -pipe \
              -m32

aflags =  ${cflags} -D__ASSEMBLY__
ldflags = -m elf_i386

default: elf_grub

liba16.s.o: liba16.s
	gcc ${aflags} -c $< -o $@

init.s.o: init.s
	gcc ${aflags} -c $< -o $@

main.c.o: main.c
	gcc ${cflags} -c $< -o $@


# 使用 grub 启动 elf
elf_grub: init.s.o liba16.s.o main.c.o
	ld -m elf_i386 -T elf_grub.ld -o kernel.bin $?
	mdel c:/kernel.bin
	mcopy kernel.bin c:/
clean:
	rm -f *.o
	rm -f *.bin
